/**
 * Copyright (c) 2020 kedacom
 * OpenATC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 * http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 **/
<template>
  <div class="search-panel">
    <div class="shrink-button" @click="handleShrink">
      <svg-icon v-if="!isShrink" icon-class="search-xiala" className="shousuo-icon"></svg-icon>
      <svg-icon v-if="isShrink" icon-class="search-shouqi" className="shousuo-icon"></svg-icon>
    </div>
    <div class="search-input">
      <el-input
        v-model="searchfilter"
        :placeholder="$t('openatc.common.searchplaceholder')"
        style="width: 266px;"
        @keyup.enter.native="doSearch()"
        @focus="focusSearchInput">
        </el-input>
    </div>
    <div class="search-button">
      <el-button type="primary" icon="el-icon-search" @click="doSearch"></el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'searchPanel',
  data () {
    return {
      searchfilter: ''
    }
  },
  props: {
    isShrink: {
      type: Boolean,
      default: false
    }
  },
  watch: {

  },
  methods: {
    focusSearchInput () {
      this.$emit('changeShrink', true)
    },
    handleShrink () {
      this.$emit('changeShrink', !this.isShrink)
    },
    doSearch () {
      this.$emit('changeShrink', true)
      this.$emit('doSearch', this.searchfilter)
    }
  },
  mounted () {

  }
}
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
</style>
<style lang="scss" rel="stylesheet/scss">
</style>
